<template>
	<view class="badge-content" v-if="num">
		<text class="num">{{num}}</text>
	</view>
</template>

<script>
	import {
		debounce
	} from '@/common/js/util.js';

	export default {
		name: 'Badge',
		components: {
			
		},
		props: {
			productId: {
				type: String
			}
		},
		computed: {
			num() {
				const cartList = this.$store.state.cartList || [];
				const carts = cartList.filter(item => !item.couponId && item.productId === this.productId);

				let num = carts.reduce((acc, item) => {
					return acc + item.productCount;
				}, 0);
				
				return num;	
			}
		},
		mounted() {
			
		},
		methods: {
			
		}
	};
</script>

<style lang="less" scoped>
	@import './badge.less';
</style>
